//小程序api   promis封装

//获取用户授权状态
//api地址https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/wx.getSetting.html
export const getSetting = () => {
    return new Promise((resolve, reject) => {
        wx.getSetting({
            success: (res) => {
                resolve(res)
            },
            fail: (err) => {
                reject(err)
            }
        })
    })
}
//获取用户收货地址
//api地址https://developers.weixin.qq.com/miniprogram/dev/api/open-api/address/wx.chooseAddress.html
export const chooseAddress = () => {
    return new Promise((resolve, reject) => {
        wx.chooseAddress({
            success: (res) => {
                resolve(res)
            },
            fail: (err) => {
                reject(err)
            }
        })
    })
}
//调起客户端小程序设置界面
//api地址https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/wx.openSetting.html
export const openSetting = () => {
    return new Promise((resolve, reject) => {
        wx.openSetting({
            success: (res) => {
                resolve(res)
            },
            fail: (err) => {
                reject(err)
            }
        })
    })
}
//显示模态对话框
//api地址https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
export const showModal = (content) => {
    return new Promise((resolve, reject) => {
        wx.showModal({
            title: '提示',
            content: content,
            success: (res) => {
                resolve(res)
            },
            fail: (err) => {
                reject(err)
            }
        })
    })
}
//显示消息提示框
//api地址
export const showToast = (title) => {
    return new Promise((resolve, reject) => {
        wx.showToast({
            title: title,
            icon: 'error',
            success: (res) => {
                resolve(res)
            },
            fail: (err) => {
                reject(err)
            }
        })
    })
}